package com.oig.sys.base.dao;

import com.oig.sys.base.entity.TbCurrRate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
@author wuxl
*/
public interface ITbCurrRateDao extends JpaRepository<TbCurrRate, Integer> {

	TbCurrRate getTbCurrRateById(Integer id);


	TbCurrRate getByCurrencyAndCustomsFlag(String currency, String customsFlag);


	List<TbCurrRate> findByCustomsFlag(String customsFlag);

	@Query("select c from TbCurrRate c where c.currency in :currList and  date_format(c.rateTime, '%Y-%m') = :yearMonth and c.customsFlag = :customsFlag")
	List<TbCurrRate> findAllByCurrAndYearMonth(@Param("currList")List<String> currList, @Param("yearMonth") String yearMonth,
												  @Param("customsFlag")String customsFlag);

	List<TbCurrRate> findAllByCurrencyAndCustomsFlag(String currency, String customsFlag);
}
